package com.freeter.common.util;

import eu.bitwalker.useragentutils.UserAgent;

public class UserAgentUtil {
    public static String parse(String userAgentString) {
        UserAgent userAgent = UserAgent.parseUserAgentString(userAgentString);
        if(null == userAgent){
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("浏览器：").append(userAgent.getBrowser()==null?"":userAgent.getBrowser().toString())
                .append(" 浏览器版本：").append(userAgent.getBrowserVersion()==null?"": userAgent.getBrowserVersion().getVersion())
                .append(" 操作系统:").append(userAgent.getOperatingSystem()==null?"": userAgent.getOperatingSystem().toString())
                .append(" id:").append(userAgent.getId());
        return  sb.toString();
    }
}
